package com.snjgm.wifi;

import android.content.Context;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;

import androidx.core.content.ContextCompat;

import java.util.List;

/**
 * @author: snjgm
 * data: 2022/8/11
 * description:
 */
public class WifiManagerTest {
    private Context context;
    private WifiManager mWifiManager;
    private WifiConfiguration mWifiConfiguration;

    public void openWifi(){
        //打开wifi开关
        mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        if(!mWifiManager.isWifiEnabled()){
            mWifiManager.setWifiEnabled(true);
        }
    }
    //扫描热点,扫描耗时操作，如果界面中需要展示进度条打画，建议将扫描操作放到子线程中操作;
    public void scanWifi(){
        mWifiManager.startScan();
        List<ScanResult> scanResults = mWifiManager.getScanResults();
//        mWifiConfiguration = mWifiManager.getConfiguredNetworks();
    }


}
